﻿<Page x:Class="EduAssess.Views.TestListPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=TestListPageViewModel}"
      mc:Ignorable="d"
      Title="TestListPage" Height="450" Width="800">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <UniformGrid Columns="3"
                     Margin="10,10,35,10">
            <TextBlock Text="Название"
                       HorizontalAlignment="Center"
                       FontSize="18"/>
            <TextBlock Text="Количество вопросов"
                       HorizontalAlignment="Center"
                       FontSize="18"/>
            <TextBlock Text="Действия"
                       HorizontalAlignment="Center"
                       FontSize="18"/>
        </UniformGrid>

        <ScrollViewer Grid.Row="1">
            <ListBox ItemsSource="{Binding Tests}"
                     HorizontalContentAlignment="Stretch"
                     Padding="7"
                     SelectedItem="{Binding SelectedTest}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <UniformGrid Columns="3">
                            <TextBlock Text="{Binding Name}"
                                   HorizontalAlignment="Center"
                                   FontSize="18"/>
                            <TextBlock Text="{Binding QuestionCount}"
                                   HorizontalAlignment="Center"
                                   FontSize="18"/>
                            <Grid HorizontalAlignment="Center">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>

                                <Button Content="Начать"
                                        FontSize="8"
                                        Grid.Column="0"
                                        Margin="5"
                                        Padding="5,0"
                                        Command="{Binding RelativeSource={RelativeSource AncestorType=Page}, Path=DataContext.OpenTestCommand}"
                                        CommandParameter="{Binding Id}"/>

                                <Button Content="Редактировать"
                                FontSize="8"
                                Grid.Column="1"
                                Margin="5"
                                Padding="3,0"
                                Command="{Binding RelativeSource={RelativeSource AncestorType=Page}, Path=DataContext.EditTestCommand}"
                                CommandParameter="{Binding Id}"/>

                                <Button Content="Удалить"
                                        FontSize="8"
                                        Grid.Column="2"
                                        Margin="5"
                                        Command="{Binding RelativeSource={RelativeSource AncestorType=Page}, Path=DataContext.DeleteTestCommand}"
                                        CommandParameter="{Binding Id}"/>
                            </Grid>
                        </UniformGrid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ListBox>
        </ScrollViewer>
    </Grid>
</Page>
